package com.ayf.payment.game.api.controller.platform;

import com.ayf.payment.game.api.dto.platform.MerchantReissueRecordDTO;
import com.ayf.payment.game.api.dto.platform.criteria.MerchantReissueRecordCriteria;
import com.ayf.payment.game.api.service.ReissueRecordService;
import com.ayf.payment.game.api.type.CommonConstants;
import com.ayf.payment.game.api.utils.CommonResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *
 *
 * @author wwl
 * @date 2020/3/13 18:33
 */
@RequestMapping("/t/reissueRecord")
@RestController
public class MerchantReissueRecordController {

    @Autowired
    private ReissueRecordService reissueRecordService;

    /**
     * 补发数据询
     * @param merchantDTO
     * @param selectCriteria
     * @return
     */
    @PostMapping("/selectAll")
    public CommonResult<PageInfo> selectPage(@RequestBody MerchantReissueRecordCriteria selectCriteria) {
        PageHelper.startPage(selectCriteria.getPageNum(), selectCriteria.getPageSize());
        selectCriteria.setScriptStatus(1);
        List<MerchantReissueRecordDTO> list = reissueRecordService.selectMerchantReissueRecordByPage(selectCriteria);
        PageInfo pageInfo = new PageInfo(list);
        return new CommonResult<>(CommonConstants.RETURN_SUCCESS, CommonConstants.OPERATION_SUCCESS, pageInfo);
    }

    /**
     * 删除补发记录
     * @param selectCriteria
     * @return
     */
    @PostMapping("/delReissueRecord")
    public CommonResult delReissueRecord(@RequestBody MerchantReissueRecordCriteria selectCriteria) {
        reissueRecordService.delByIds(selectCriteria.getIds());
        return new CommonResult(CommonConstants.RETURN_SUCCESS, CommonConstants.OPERATION_SUCCESS, "");
    }
}
